/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package DBManager;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.ResourceBundle;

/**
 *
 * @author Alex
 */
public class DBConnection {
      public static String driver, url, username,password;

    public DBConnection()
    {
        //Get the data from the dbcredentials.properties
        ResourceBundle settings =
                ResourceBundle.getBundle("credentials");
        driver = settings.getString("driver");
        url = settings.getString("url");
        username = settings.getString("username");
        password = settings.getString("password");

    }

    public Connection getConnection()
    {
        try{
            //Connect to the driver
            Class.forName(driver);

            //acquires database connection
            Connection conn =
              DriverManager.getConnection(url,username,password);

            //retun connection
            return conn;
        }
        catch(SQLException ex){
        }
        catch(ClassNotFoundException ex){
        }

        return null;
    }
}
